A prefetch unit is usually put between caches in different levels of hierarchy in order to alleviate the latency of access of the slower cache. A prefetcher identifies data streams and speculatively pre-fetches the next data line before requested by the processor. A prefetcher stores the data that it prefetched in a buffer whose size is a premium. This type of prefetching is useful only if future accesses can be predicted successfully.
A processor can continually request data from sequential addresses in which case the request pattern is said to be from a ‘single’ stream. On the other hand, if the request pattern of addresses from a processor is “Addr ‘A’, Addr ‘B’, Address ‘A+1’, Address ‘B+1’ . . . ” and so on then the request pattern is said to be from ‘multiple’ streams which in this case is 2, that is, from streams A and B.
A prefetcher, incorporated between an L1 and L2 cache, in response to an L1 cache line miss from the processor usually fetches ‘b’ bytes from the L2 cache. If ‘x’ bytes per cycle are used on an average by the processor and if the latency to fetch from the L2 cache is “k” cycles, then the prefetcher should have a depth of ‘x’ times ‘k’ bytes so that the processor would continually get hits in the prefetch buffer.
In a single stream request pattern, it is likely that the latency to get the data from the lower level memory exceeds the time needed by a processor to consume the data line. If a processor is fetching data belonging to a single data stream only, a prefetch engine which does not prefetch the required depth may not be able to keep up. Thus, the depth of prefetch should be high if the request pattern is from a singe stream. On the other hand, the depth of prefetch can be reduced if the requests are from multiple streams.
If a prefetcher does not distinguish between single and multiple streams and fetches the worst case prefetch depth required, then it would not be able to sustain as many streams as a prefetcher which adaptively chooses the prefetch depth. Therefore, what is desirable is a method and apparatus of prefetching streams of varying prefetch depth.